package cn.xuqiudong.rpc.proxy.jdk;

import cn.xuqiudong.rpc.proxy.ProxyFactory;

import java.lang.reflect.Proxy;

/**
 * 描述: 基于jdk的动态代理工厂
 * @author Vic.xu
 * @date 2022-02-23 10:07
 */
public class JdkProxyFactory implements ProxyFactory {

    @Override
    public <T> T getProxy(Class<T> clazz) {
        return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{clazz}, new JdkProxyInvocation(clazz));
    }
}
